package com.cltech.util;

import org.apache.commons.codec.binary.Base64;
import org.apache.commons.codec.digest.DigestUtils;

import java.io.UnsupportedEncodingException;
import java.security.SecureRandom;
import java.util.Random;

/**
 * Created by Administrator on 2018/12/8.
 */
public class PasswordUtil {
    public static String generateMd5WithSalt(String password,String account,String salt) {
        return DigestUtils.md5Hex(password+account+salt);
    }
    public static String generateSalt(){
        Random RANDOM = new SecureRandom();
        byte[] salt = new byte[16];
        RANDOM.nextBytes(salt);
        return Base64.encodeBase64String(salt);
    }
}
